<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class User_Model_Feed extends Zend_Db_Table_Abstract {

    protected $_name = TABLE_FEED;
    protected $_id = 'id';

    public function updateFeed() {
        
    }

    public function getFeedByUser($userId) {
        
    }

    public function getFeedById($feedid) {
        $where = 'f.feed_id ="' . $feedid . '"';
        $select = $this->select()
                ->setIntegrityCheck(false)
                ->from(array('f' => $this->_name))
                ->join(array('fv' => TABLE_FEED_VALUE), 'f.feed_type = fv.value_id')
                ->where($where);
        return $this->fetchRow($select)->toArray();
    }
    
    public function getFeedContent(){
        $where = 'f.feed_id ="' . $feedid . '"';
        $select = $this->select()
                ->setIntegrityCheck(false)
                ->from(array('f' => $this->_name))
                ->where($where);
        return $this->fetchRow($select)->toArray();
    }

    public function getFeed($userid, $rowCount=10, $page=1) {
        $where = 'f.user_id = "' . $userid . '" OR f.friend_id= "' . $userid . '"';
        $select = $this->select()
                ->setIntegrityCheck(false)
                ->from(array('f' => $this->_name))
                ->join(array('fv' => TABLE_FEED_VALUE), 'f.feed_type = fv.value_id')
                ->where($where)
                ->order('f.feed_create DESC')
                ->limitPage($page, $rowCount);
        return $this->fetchAll($select)->toArray();
    }

}

?>
